package com.shujia.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

/**
* @Description: MySQLJDBC3 删除
* @Author: 王火火
* @Date: 2019/9/6 14:41
*/

public class MySQLJDBC3 {
    //创建常量
    static final String DRIVER = "com.mysql.jdbc.Driver";//驱动
    static final String URL = "jdbc:mysql://master:3306/shujia";//路劲
    static final String USERNAME = "root";//用户名
    static final String PASSWORD = "123456";//密码
    public static void main(String[] args) throws Exception{
        //加载驱动
        Class.forName(DRIVER);
        //获取连接
        Connection conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
        String sql="delete from emp where empno=123456";
        //获取执行器
        PreparedStatement ps = conn.prepareStatement(sql);
        int i = ps.executeUpdate();
        System.out.println(i);
        ps.close();
        conn.close();
    }
}
